<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        str1 = "Hello, World!"
        function first(str) {
            if (str.includes("World")) {
                let newStr = str.replace("World", "Harmony")
                return newStr;
            }
        }
        console.log(first(str1))

        photoNum = "13812345678"
        function pN(num) {
            let newStr = num.substr(0, 3) + "****" + num.substr(-4, 4)
            return newStr;
        }
        console.log(pN(photoNum))

        str = 'asdasdSMasdasdasdSMsdasdasdSMsadasd'
        function SM(str) {
            let newArr = str.split('SM')
            let newStr = newArr.join("**")
            return newStr;
        }
        console.log(SM(str))

        strabc = "abcdefg"
        function abc(str) {
            let Arr = str.split('')
            let newArr = Arr.reverse()
            let newStr = newArr.join('')
            return newStr;
        }
        console.log(abc(strabc))

        url = "https://example.com?name=鸿蒙&id=1234&lang=zh"
        function id(url) {
            let a = url.indexOf("id=")
            let str1 = url.substr(a + 3)
            let b = str1.indexOf("&")
            let str2 = str1.substring(0, b)
            return str2;
        }
        console.log(id(url))

        function id2(url) {
            let arr1 = url.split('?')
            let value = arr1[1]
            let arr2 = value.split('&')
            for (let i = 0; i < arr2.length; i++){
                let str = arr2[i]
                let arr3 = str.split("=")
                // let str0 = arr3[0]
                // let str1 = arr3[1]
                // console.log(`${arr3[0]}:${arr3[1]}`)
                if (arr3[0] == "id") {
                    return arr3[1];
                }
            }
        }
        console.log(id2(url))
    </script>
</body>
</html>